import { ref } from 'vue'

const useDefer = (count: number) => {
  const displayPriority = ref(0)
  const runDisplayPriority = () => {
    const step = () =>
      requestAnimationFrame(() => {
        displayPriority.value++
        if (displayPriority.value < count) {
          step()
        }
      })
    step()
  }
  return {
    displayPriority,
    runDisplayPriority,
  }
}

export default useDefer
